﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PS.Stereotypes
{
    public sealed class StereotypeFactory
    {
        private static int counter = 0;
        public static StereotypeFactory Instance = new StereotypeFactory();

        // Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
        static StereotypeFactory()
        {
        }

        private StereotypeFactory()
        {
        }

        public List<Stereotype> GetRandomStereotype()
        {
            var s = new List<Stereotype>();

            switch (counter)
            {
                case 0:
                    s = GetMeABoor();
                    break;
                case 1:
                    s = GetMeABoorBusinessman();
                    break;
                case 2:
                    s = GetMeABusinessman();
                    break;
                case 3:
                    s = GetMeAGentleman();
                    break;
                case 4:
                    s = GetMeAGentlemanlikeGrandma();
                    break;
                case 5:
                    s = GetMeAGrandma();
                    
                    // reset counter
                    counter = -1;
                    break;
                default:
                    s = GetMeABoor();
                    break;
            }

            counter++;
            return s;
        }

        private List<Stereotype> GetMeAGentlemanlikeGrandma()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Grandma());
            s.Add(new Gentleman());
            return s;
        }

        private List<Stereotype> GetMeABoorBusinessman()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Businessman());
            s.Add(new Boor());
            return s;
        }

        private List<Stereotype> GetMeAGrandma()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Grandma());
            return s;
        }

        private List<Stereotype> GetMeAGentleman()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Gentleman());
            return s;
        }

        private List<Stereotype> GetMeABoor()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Boor());
            return s;
        }

        private List<Stereotype> GetMeABusinessman()
        {
            List<Stereotype> s = new List<Stereotype>();
            s.Add(new Businessman());
            return s;
        }
    }
}
